import request from '@/utils/request'

export function getList(params) {
  return request({
    url: '/form/all',
    method: 'GET',
    baseURL: 'http://210.42.37.244:8080'
  })
}

export function formatDate(date1, fmt) {
  var date = new Date(date1)
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  }
  const o = {
    'M+': date.getMonth() + 1,
    'd+': date.getDate(),
    'h+': date.getHours(),
    'm+': date.getMinutes(),
    's+': date.getSeconds()
  }
  for (const k in o) {
    if (new RegExp(`(${k})`).test(fmt)) {
      const str = o[k] + ''
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str))
    }
  }
  return fmt
}

function padLeftZero(str) {
  return ('00' + str).substr(str.length)
}

export function getname(params) {
  return request({
    url: '/form/formname',
    method: 'GET',
    params: params,
    baseURL: 'http://210.42.37.244:8080'
  })
}

export function searchall(params) {
  return request({
    url: '/form/searchall',
    method: 'GET',
    params: params,
    baseURL: 'http://210.42.37.244:8080'
  })
}

// export function getcollege(params) {
//   return request({
//     url: '/form/formcollege',
//     method: 'GET',
//     params: params,
//     baseURL: 'http://210.42.37.244:8080'
//   })
// }

// export function getfield(params) {
//   return request({
//     url: '/form/formfield',
//     method: 'GET',
//     params: params,
//     baseURL: 'http://210.42.37.244:8080'
//   })
// }

export function gettime(params) {
  return request({
    url: '/form/time',
    method: 'GET',
    params: params,
    baseURL: 'http://210.42.37.244:8080'
  })
}

// export function searchname(params) {
//   return request({
//     url: '/form/searchn',
//     method: 'GET',
//     params: params,
//     baseURL: 'http://210.42.37.244:8080'
//   })
// }
